package com.qidianit.mes.pro.service.impl;

import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.Workstation;
import com.qidianit.mes.pro.mapper.ProcessMapper;
import com.qidianit.mes.pro.mapper.WorkshopMapper;
import com.qidianit.mes.pro.mapper.WorkstationMapper;
import com.qidianit.mes.pro.service.WorkStationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ Description:
 * @ Author:WuJingLei
 * @ Date: 2025/9/24 -15:52
 */
@Service
public class WorkStationServiceImpl implements WorkStationService {
    @Autowired
    private WorkstationMapper workstationMapper;
    @Autowired
    private ProcessMapper processMapper;
    @Autowired
    private WorkshopMapper workshopMapper;

    @Override
    public Result<List<Workstation>> queryList(Workstation workstation) {
        List<Workstation> workstations = workstationMapper.queryList(workstation);
        workstations.forEach(workstation1 -> {
            workstation1.setProcess(processMapper.queryById(workstation1.getProcessId()));
            workstation1.setWorkshop(workshopMapper.queryById(workstation1.getWorkshopId()));
        });
        return Result.success(workstations);
    }
}
